<?php

namespace Acme\TaskBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Acme\TaskBundle\Entity\Task;
use Symfony\Component\HttpFoundation\Request;
use Acme\TaskBundle\Form\Type\TaskType;

class DefaultController extends Controller
{
    public function newAction(Request $request)
    {
        // create a task and give it some dummy data for this example
        $task = new Task();
        $task->setTask('Write a blog post');
        $task->setDueDate(new \DateTime('tomorrow'));

        $form = $this->createForm('task', $task);
        $form->handleRequest($request);
        if ($form-> isValid()) {
            // ... perform some action, such as saving the task to the database
            $nextAction = $form->get('saveAndAdd')->isClicked() ? 'taxk_new' : 'task_success';
        }

        return $this->render('AcmeTaskBundle:Default:haha.html.twig', array(
            'form' => $form->createView(),
        ));
    }
}